package com.labyrinth.core;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Texture;

public abstract class GameObject
{
	Mesh mesh;
	Texture texture;
	float scaleX;
	float scaleY;
	int drawType;
	int vertexCount;
	Vector2D position;

	GameObject()
	{

	}

	GameObject(float x, float y)
	{
		position = new Vector2D(x, y);
	}

	float getX()
	{
		return position.getX();
	}

	float getY()
	{
		return position.getY();
	}

	void setDrawType(int drawType)
	{
		this.drawType = drawType;
	}

	float getScaleX()
	{
		return scaleX;
	}

	float getScaleY()
	{
		return scaleY;
	}

	void setTexture(String texturePath)
	{
		FileHandle textureFileHandle = Gdx.files.internal(texturePath);
		texture = new Texture(textureFileHandle);
	}

	public void setScale(float scaleX, float scaleY)
	{
		this.scaleX = scaleX;
		this.scaleY = scaleY;
	}

	void setScale(float scale)
	{
		this.scaleX = (float)100;
		this.scaleY = (float)100;
	}

	public void draw()
	{
		Gdx.gl10.glPushMatrix();
		Gdx.gl10.glTranslatef(position.getX(), position.getY(), 0);
		Gdx.gl10.glScalef(scaleX, scaleY, 0);
		Gdx.graphics.getGL10().glEnable(GL10.GL_TEXTURE_2D);

		texture.bind();
		mesh.render(drawType, 0, vertexCount);
		Gdx.gl10.glPopMatrix();
	}
	
	public void setPosition(float x, float y)
	{
		position = new Vector2D(x, y);
	}

	abstract public void setMesh();

}
